#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''微信公共接口'''

from .wx_pay import Wxpay_client_pub


# 微信消息推送
class SandBoxNews(Wxpay_client_pub):
    url = 'https://api.mch.weixin.qq.com/sandboxnew/pay/getsignkey' 
   
    def createXml(self):
        self.parameters = {"mch_id":WxPayConf_pub.MCHID, #商户号
                          "nonce_str": self.createNoncestr(), #随机字符串
                          }
        self.parameters.update(sign=self.getSign(self.parameters))
        return self.arrayToXml(self.parameters)

    def get_key(self):
        self.postXml()
        self.result = self.xmlToArray(self.response)
        if self.result.get('return_code') != "SUCCESS":
            raise ValueError(self.result.get("return_msg"))
        return self.result.get('sandbox_signkey')
